<template>
  <div class="feature-card-wrapper">
    <!-- <SvgFilters /> -->
    <div class="feature-card" @click="$emit('click')">
    <div class="card-header">
      <div class="card-icon">{{ icon }}</div>
      <div v-if="category" :class="['category-badge', `category-${category}`]">
        {{ getCategoryName(category) }}</div>
    </div>
    <h3 class="card-title">{{ title }}</h3>
    <p class="card-description">{{ description }}</p>
    <div class="card-footer">
      <div class="card-arrow">→</div>
    </div>
    </div>
  </div>
</template>

<script setup>
import { useThemeStore } from '@store/theme'
import { computed } from 'vue'
import SvgFilters from './SvgFilters.vue'

const themeStore = useThemeStore()
const currentTheme = computed(() => themeStore.appTheme)

defineProps({
  title: String,
  description: String,
  icon: String,
  category: String
})

defineEmits(['click'])

// 获取分类名称
const getCategoryName = (category) => {
  const categoryMap = {
    'core': '核心',
    'api': 'API',
    'typescript': 'TS',
    'performance': '性能',
    'component': '组件',
    'animation': '动画',
    'state': '状态',
    'advanced': '高级'
  }
  return categoryMap[category] || ''
}
</script>

<style scoped>
/* 定义CSS变量 */
:root {
  --card-border-radius: 16px;
  --transition-speed: 0.3s;
  --shadow-hover: 0 20px 40px rgba(0, 0, 0, 0.1);
  
  /* 分类颜色 */
  --color-core: #6366f1;      /* 靛蓝色 */
  --color-api: #8b5cf6;       /* 紫色 */
  --color-typescript: #3b82f6; /* 蓝色 */
  --color-performance: #10b981; /* 绿色 */
  --color-component: #f59e0b;  /* 橙色 */
  --color-animation: #ec4899;  /* 粉色 */
  --color-state: #64748b;      /* 石板色 */
  --color-advanced: #14b8a6;    /* 青色 */
}

.feature-card-wrapper {
  position: relative;
  /* 确保滤镜正确应用 */
}

/* Feature Card 主样式 */
.feature-card {
  /* 使用SVG滤镜实现液态玻璃效果 */
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  filter: url(#liquidGlass);
  /* Apple标准圆角 - 更柔和的曲线 */
  border-radius: 18px;
  padding: 1.5rem;
  /* Apple标准过渡曲线 */
  transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 200px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

/* 深色模式样式 */
[data-theme="dark"] .feature-card {
  /* 深色模式玻璃效果 */
  background: rgba(30, 30, 30, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  filter: url(#liquidGlass);
}

/* 悬停效果 - 符合Apple人机界面指南 */
.feature-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
}

/* 深色主题悬停效果 */
[data-theme="dark"] .feature-card:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  border-color: rgba(129, 140, 248, 0.3);
}

/* 点击效果 - Apple标准的反馈 */
.feature-card:active {
  transform: translateY(0);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .feature-card:active {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* 深色主题特定样式 */
[data-theme="dark"] .feature-card .card-title {
  color: #ffffff;
  text-shadow: none;
  font-weight: 500;
}

[data-theme="dark"] .feature-card .card-description {
  color: #94a3b8;
}

[data-theme="dark"] .feature-card .card-arrow {
  color: #818cf8;
}

/* 悬停时箭头动画 */
.feature-card:hover .card-arrow {
  transform: translateX(5px);
}

/* 卡片头部 */
.feature-card .card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

/* 卡片图标 */
.feature-card .card-icon {
  font-size: 2.75rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

/* 分类徽章基础样式 */
.feature-card .category-badge {
  /* Apple风格的徽章设计 */
  padding: 0.25rem 0.65rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: all 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
  
  /* 精致的背景和边框 - 应用基础液态玻璃滤镜 */
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  filter: url(#liquidGlass);
  
  /* 微小的阴影效果 */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 各分类颜色样式 */
.feature-card .category-badge.category-core {
  background-color: rgba(99, 102, 241, 0.1);
  color: var(--color-core);
  border-color: rgba(99, 102, 241, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.feature-card .category-badge.category-api {
  background-color: rgba(139, 92, 246, 0.1);
  color: var(--color-api);
  border-color: rgba(139, 92, 246, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.feature-card .category-badge.category-typescript {
  background-color: rgba(59, 130, 246, 0.1);
  color: var(--color-typescript);
  border-color: rgba(59, 130, 246, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.feature-card .category-badge.category-performance {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--color-performance);
  border-color: rgba(16, 185, 129, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.feature-card .category-badge.category-component {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--color-component);
  border-color: rgba(245, 158, 11, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.feature-card .category-badge.category-animation {
  background-color: rgba(236, 72, 153, 0.1);
  color: var(--color-animation);
  border-color: rgba(236, 72, 153, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.feature-card .category-badge.category-state {
  background-color: rgba(100, 116, 139, 0.1);
  color: var(--color-state);
  border-color: rgba(100, 116, 139, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.feature-card .category-badge.category-advanced {
  background-color: rgba(20, 184, 166, 0.1);
  color: var(--color-advanced);
  border-color: rgba(20, 184, 166, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* 悬停时分类徽章效果 */
.feature-card:hover .category-badge {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.feature-card:hover .category-badge.category-core {
  background-color: rgba(99, 102, 241, 0.15);
}

.feature-card:hover .category-badge.category-api {
  background-color: rgba(139, 92, 246, 0.15);
}

.feature-card:hover .category-badge.category-typescript {
  background-color: rgba(59, 130, 246, 0.15);
}

.feature-card:hover .category-badge.category-performance {
  background-color: rgba(16, 185, 129, 0.15);
}

.feature-card:hover .category-badge.category-component {
  background-color: rgba(245, 158, 11, 0.15);
}

.feature-card:hover .category-badge.category-animation {
  background-color: rgba(236, 72, 153, 0.15);
}

.feature-card:hover .category-badge.category-state {
  background-color: rgba(100, 116, 139, 0.15);
}

.feature-card:hover .category-badge.category-advanced {
  background-color: rgba(20, 184, 166, 0.15);
}

/* 深色主题下的分类标签样式 */
[data-theme="dark"] .feature-card .category-badge.category-core {
  background-color: rgba(99, 102, 241, 0.12);
  color: rgba(99, 102, 241, 0.9);
  border-color: rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .feature-card .category-badge.category-api {
  background-color: rgba(139, 92, 246, 0.12);
  color: rgba(139, 92, 246, 0.9);
  border-color: rgba(139, 92, 246, 0.2);
}

[data-theme="dark"] .feature-card .category-badge.category-typescript {
  background-color: rgba(59, 130, 246, 0.12);
  color: rgba(59, 130, 246, 0.9);
  border-color: rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .feature-card .category-badge.category-performance {
  background-color: rgba(16, 185, 129, 0.12);
  color: rgba(16, 185, 129, 0.9);
  border-color: rgba(16, 185, 129, 0.2);
}

[data-theme="dark"] .feature-card .category-badge.category-component {
  background-color: rgba(245, 158, 11, 0.12);
  color: rgba(245, 158, 11, 0.9);
  border-color: rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .feature-card .category-badge.category-animation {
  background-color: rgba(236, 72, 153, 0.12);
  color: rgba(236, 72, 153, 0.9);
  border-color: rgba(236, 72, 153, 0.2);
}

[data-theme="dark"] .feature-card .category-badge.category-state {
  background-color: rgba(100, 116, 139, 0.12);
  color: rgba(100, 116, 139, 0.9);
  border-color: rgba(100, 116, 139, 0.2);
}

[data-theme="dark"] .feature-card .category-badge.category-advanced {
  background-color: rgba(20, 184, 166, 0.12);
  color: rgba(20, 184, 166, 0.9);
  border-color: rgba(20, 184, 166, 0.2);
}

/* 深色主题下悬停时分类徽章效果 */
[data-theme="dark"] .feature-card:hover .category-badge {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .feature-card:hover .category-badge.category-core {
  background-color: rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .feature-card:hover .category-badge.category-api {
  background-color: rgba(139, 92, 246, 0.2);
}

[data-theme="dark"] .feature-card:hover .category-badge.category-typescript {
  background-color: rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .feature-card:hover .category-badge.category-performance {
  background-color: rgba(16, 185, 129, 0.2);
}

[data-theme="dark"] .feature-card:hover .category-badge.category-component {
  background-color: rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .feature-card:hover .category-badge.category-animation {
  background-color: rgba(236, 72, 153, 0.2);
}

[data-theme="dark"] .feature-card:hover .category-badge.category-state {
  background-color: rgba(100, 116, 139, 0.2);
}

[data-theme="dark"] .feature-card:hover .category-badge.category-advanced {
  background-color: rgba(20, 184, 166, 0.2);
}

/* 卡片标题 */
.feature-card .card-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #1e293b;
  line-height: 1.3;
  /* 细微的文字阴影增加层次感 */
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

/* 卡片描述 */
.feature-card .card-description {
  font-size: 1rem;
  color: #64748b;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  flex: 1;
}

/* 卡片底部 */
.feature-card .card-footer {
  display: flex;
  justify-content: flex-end;
}

/* 卡片箭头 */
.feature-card .card-arrow {
  font-size: 1.25rem;
  color: #6366f1;
  transition: transform var(--transition-speed) ease;
  font-weight: 600;
}

/* 卡片底部装饰效果 - Apple风格的细微渐变 */
.feature-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #6366f1 0%, #8b5cf6 100%);
  transform: translateX(-100%);
  transition: transform var(--transition-speed) ease;
  border-radius: 3px;
}

.feature-card:hover::after {
  transform: translateX(0);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .feature-card {
    padding: 1.5rem;
    min-height: 200px;
  }
  
  .feature-card .card-icon {
    font-size: 2.25rem;
  }
  
  .feature-card .card-title {
    font-size: 1.25rem;
  }
}

@media (max-width: 480px) {
  .feature-card {
    padding: 1.25rem;
    min-height: 180px;
  }
  
  .feature-card .card-icon {
    font-size: 2rem;
  }
  
  .feature-card .card-title {
    font-size: 1.15rem;
  }
  
  .feature-card .card-description {
    font-size: 0.95rem;
  }
}
</style>